home *** CD-ROM | disk | FTP | other *** search
- 10 ' SHELDEMO.BAS
- 20 '
- 30 ' March 14, 1984
- 40 '
- 50 ' Written by Wes Meier (70215,1017)
- 60 '
- 70 ' RBBS - (415)-937-0156 ...... the Walnut Creek RBBS.
- 80 '
- 90 ' ───────────────────────────────────────────────────────────────────────
- 100 ' A Demonstration of the undocumented BASIC 2.00 SHELL command.
- 110 '───────────────────────────────────────────────────────────────────────
- 120 ' Syntax: SHELL "dos command" OR SHELL stringvar (where stringvar
- 130 ' has been set equal to a valid DOS command).
- 140 '───────────────────────────────────────────────────────────────────────
- 150 ' Comments:
- 160 '
- 170 ' 1) The SHELL command works in that it WILL execute any valid DOS
- 180 ' command from BASIC. The problem is that the pointers used by
- 190 ' BASIC to indicate the start of program text are clobbered by the
- 200 ' SHELL routine's execution. Hence, upon return from the execution
- 210 ' of a command, poor old BASIC doesn't have the slightest idea where
- 220 ' to restart execution of a program which has ended or has been
- 230 ' redirected by a gosub, goto, etc.
- 240 '
- 250 ' Fortunately, SHELL does NOT clobber variables. So, if we look up
- 260 ' the value of the "start of program text" pointers and assign their
- 270 ' values to variables, we can POKE the values back into the
- 280 ' locations that BASIC expects to see them. This two byte pointer is
- 290 ' located at relative bytes 30H and 31H in BASIC's segment. See the
- 300 ' Technical Reference Manual, page 3-23.
- 310 '
- 320 ' 2) It apprears that SHELL moves both BASIC and program text up into
- 330 ' high memory and then moves it back down again after execution. This
- 340 ' can cause problems if the DOS command executes a large program and
- 350 ' overwrites THIS area of memory. EG, SHELL "1-2-3" would most likely
- 360 ' blow your resident BASIC driver program away. Stick with the
- 370 ' utility commands like CHKDSK, DIR, MODE, etc. Most .COM programs
- 380 ' load into low memory while MANY (but not all) .EXE programs load
- 390 ' into high memory which would generally cause you to take a trip
- 400 ' to where Peter Pan lives.
- 410 '
- 420 ' 3) The current cursor location (in BASIC) is NOT updated to account
- 430 ' for any screen I/O generated by the DOS command executed.
- 440 '
- 450 ' 4) SHELL was left undocumented for good reason. It probably has
- 460 ' bugs that were not ironed out by our friends at Microsoft by the
- 470 ' time Big Blue wanted to release BASIC 2.00. USE IT WITH CAUTION!
- 480 '
- 490 ' One "bug" (feature?) I've found is that it's easy to confuse
- 500 ' SHELL and/or DOS (running via SHELL) into staying at the DOS
- 510 ' prompt. If you try to get back to BASIC(A), you'll get a charming
- 520 ' error message that states "You cannot run Basic as a Child of
- 530 ' Basic." I suspect that this prevents recursive loops.
- 540 '───────────────────────────────────────────────────────────────────────
- 550 ' The following short program demonstrates a relatively successful way
- 560 ' to use the SHELL command. --- Good Luck! ---
- 570 ' - Wes
- 580 '───────────────────────────────────────────────────────────────────────
- 590 CLS
- 600 DEF SEG ' Set the segment register to BASIC's default.
- 610 '
- 620 LSB=PEEK(&H30) ' Get the Least Significant Byte of the pointer.
- 630 MSB=PEEK(&H31) ' Get the Most Significant Byte of the pointer.
- 640 '
- 650 PRINT
- 660 LINE INPUT"Enter DOS Command to be executed ";DOS.COMMAND$
- 670 '
- 680 SHELL DOS.COMMAND$ ' Execute the command entered.
- 690 '
- 700 ' At this point, BASIC's pointers at 30H and 31H have been ZAPPED.
- 710 ' We need to reload them.....
- 720 '
- 730 POKE &H30,LSB ' Reload the LSB of the pointer.
- 740 POKE &H31,MSB ' Reload the MSB of the pointer.
- 750 '
- 760 GOTO 650 ' Go back for another run.
- 770 '
- 780 ' Last line of SHELDEMO.BAS.
-